import { _ajaxTool } from "./_ajax.js";

window.onload = async () => {
    let carousel_box = document.querySelector(".carousel_box");
    try {
        // 账号密码
        let useInfo = {
            phone: "13100000000",
            password: "123456"
        }
        // 加载登录
        let loginRes = await _ajaxTool("POST", "http://website.bluej.cn/api/admin/login", useInfo);

        // 存token
        console.log(loginRes, loginRes.data.token);
        window.sessionStorage.setItem("x-token", loginRes.data.token);

        // 获取轮播图
        let carouselFormat = {
            limit: 9999,
            offset: 0
        }
        let carouselRes = await _ajaxTool("GET", "http://website.bluej.cn/api/carouselGroup/getAllCarouselGroup", carouselFormat);

        let carouselArr = carouselRes.data.rows[0].Carousels;
        console.log(carouselArr);
    } catch (err) {
        console.log(err);
    }
}